package com.manor.main.utils;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.TextView;

import com.noober.background.drawable.DrawableCreator;
import com.manor.common.utils.DpUtil;
import com.manor.main.R;

import java.util.Random;

/**

 * @version 1.0

 * @date 2020/6/18  14:00
 */
public class CustomizedUtil {

    public static CustomizedUtil instance = null;

    static {
        if (instance == null) {
            instance = new CustomizedUtil();
        }
    }

    private CustomizedUtil() {
    }


    public void setSolid(TextView tv,Context context) {
        Drawable drawable4 = new DrawableCreator.Builder()
                .setCornersRadius(DpUtil.dp2px(5))
                .setSolidColor(getCustomizedColor(context))
                .build();
        tv.setBackground(drawable4);
    }


    public int getCustomizedColor(Context context) {
        int[] customizedColors = context.getResources().getIntArray(R.array.customizedColors);
        int customizedColor = customizedColors[new Random().nextInt(customizedColors.length)];
        return customizedColor;
    }

}
